package com.moonshineproject.utils
{
	import flash.filesystem.File;
	import flash.filesystem.FileMode;
	import flash.filesystem.FileStream;
	
	public class FileUtil
	{
		public static function createFile(file:File, forceIsDirectory:Boolean=false):void
		{
			if (!file.parent.exists)
			{
				FileUtil.createFile(file.parent, true);
			}
			
			if (!file.exists)
			{
				if (file.isDirectory || forceIsDirectory)
				{
					file.createDirectory();
				}
				else
				{
					var fs:FileStream = new FileStream();
					fs.open(file, FileMode.WRITE);
					fs.writeUTF("");
					fs.close();
				}
			}
		}
		
		public static function contains(dir:File, file:File):Boolean
		{
			if (file.nativePath.indexOf(dir.nativePath) == 0) return true;
			return false;
		}

	}
}